home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / DJSRC111.ZIP / drivers / atipro.asm < prev    next >
Assembly Source File  |  1993-12-07  |  6KB  |  284 lines

  1. ; This is file ATIPRO.ASM
  2. ;
  3. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. ;
  5. ; This file is distributed under the terms listed in the document
  6. ; "copying.dj", available from DJ Delorie at the address above.
  7. ; A copy of "copying.dj" should accompany this file; if not, a copy
  8. ; should be available from where this file was obtained.  This file
  9. ; may not be distributed without a verbatim copy of "copying.dj".
  10. ;
  11. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. ;
  14. ;
  15. ; Modify for the ATI VGA WONDER
  16. ; by Luc Bussieres, bussiere@dmi.usherb.ca
  17. ; University of Sherbrooke
  18. ; March 9th, 1991
  19. ;
  20. ; Version revised by Patrick Daloze, daloze@iro.umontreal.ca
  21. ; University of Montreal
  22. ; Juilly, 4th, 1991
  23. ;
  24. ; Based on ATI.ASM, modified to be used with ATI Ultra Pro
  25. ; (support for 1024x768x256 Mode)
  26. ; Tilmann Haeberle
  27. ; Institut fuer physikalische Chemie I
  28. ; Technische Universitaet Muenchen
  29. ; E-Mail: til@zentrum.phys.chemie.tu-muenchen.de
  30. ; November, 30th, 1993
  31. ; To build, use these commands:
  32. ;     masm atipro;
  33. ;     link atipro;
  34. ;     exe2bin atipro atipro.grd
  35. ;     del atipro.obj
  36. ;     del atipro.exe
  37. ;
  38.  
  39. cseg    segment    byte public 'code'
  40.     assume    cs:cseg, ds:cseg, es:cseg, ss:nothing
  41.  
  42.     dw    offset init_routine
  43.     dw    offset paging_routine
  44.     dw     1       ; set to 1 if separate read & write windows or
  45.             ; only 64K of video RAM (ie: no paging)
  46.  
  47. def_tw    dw    80    ; filled in by go32 if GO32 env. var. is set
  48. def_th     dw    25
  49. def_gw    dw     640
  50. def_gh     dw     480
  51. IO_Add  dw      0
  52.  
  53. ;--------------------------------------------------------------------------
  54. ; Entry: AX=mode selection
  55. ;        0=80x25 text
  56. ;        1=default text
  57. ;        2=text CX cols by DX rows
  58. ;        3=biggest text
  59. ;        4=320x200 graphics
  60. ;        5=default graphics
  61. ;        6=graphics CX width by DX height
  62. ;        7=biggest non-interlaced graphics
  63. ;        8=biggest graphics
  64. ;
  65. ; NOTE: This runs in real mode, but don't mess with the segment registers.
  66. ;       For mode 5 to 8 (640x480 or over): only for ATI Version 2 or more
  67. ;       (separate read and write planing).
  68. ;
  69. ; Exit:  CX=width (in pixels or characters)
  70. ;        DX=height
  71.  
  72. init_table    label    word
  73.     dw    offset init_0
  74.     dw    offset init_1
  75.     dw    offset init_2
  76.     dw    offset init_3
  77.     dw    offset init_4
  78.     dw    offset init_5
  79.     dw    offset init_6
  80.     dw    offset init_7
  81.     dw    offset init_8
  82.  
  83. init_routine    proc    far
  84.     cmp    ax,8
  85.     jbe    valid_req
  86.     ret
  87. valid_req:
  88.     shl    ax,1
  89.     mov    bx,ax
  90.     jmp    init_table[bx]
  91.  
  92. init_0: ; 80x25 text
  93.     mov    ax,3
  94.     int    10h
  95.     mov    cx,80
  96.     mov    dx,25
  97.     ret
  98.  
  99. init_1: ; default text
  100.     mov    cx,def_tw
  101.     mov    dx,def_th
  102.     jmp    init_2
  103.  
  104. init_2_table    label    word
  105.     dw    01h, 40, 25
  106.     dw    03h, 80, 25
  107.     dw      23h, 132, 25
  108.     dw      33h, 132, 44
  109. init_2_tend    label    word
  110.  
  111. init_2: ; CX*DX text
  112.     mov    si,offset init_2_table
  113. init_2a:
  114.     cmp    [si+2],cx
  115.     jb    init_2b
  116.     cmp    [si+4],dx
  117.     jb    init_2b
  118.     ; got a big enough one!
  119.     jmp    init_2c
  120. init_2b:
  121.     cmp    si,offset init_2_tend - 6
  122.     je    init_2c
  123.     add    si,6
  124.     jmp    init_2a
  125. init_2c:
  126.     mov    ax,[si]
  127.     push    si
  128.     int    10h
  129.     pop    si
  130.     mov    cx,[si+2]
  131.     mov    dx,[si+4]
  132.     ret
  133.  
  134. init_3: ; biggest text
  135.     mov    ax,[init_2_tend-6]
  136.     int    10h
  137.     mov    cx,[init_2_tend-4]
  138.     mov    dx,[init_2_tend-2]
  139.     ret
  140.  
  141. init_4: ; 320x200 graphics
  142.     mov    ax,13h
  143.     int    10h
  144.     mov    cx,320
  145.     mov    dx,200
  146.     ret
  147.  
  148. init_5: ; default graphics - should be 640x480 if supported
  149.     mov    cx,def_gw
  150.     mov    dx,def_gh
  151.     jmp    init_6
  152.  
  153. init_6_table    label    word
  154.     dw    13h, 320, 200
  155.     dw     61h, 640, 400
  156.     dw     62h, 640, 480
  157.     dw     63h, 800, 600
  158.         dw      64h, 1024, 768  ; Added by TH 30-11-93
  159. init_6_tend    label    word
  160.  
  161. init_6: ; CX*DX graphics
  162.     mov    si,offset init_6_table
  163. init_6a:
  164.     cmp    [si+2],cx
  165.     jb    init_6b
  166.     cmp    [si+4],dx
  167.     jb    init_6b
  168.     ; got a big enough one!
  169.     jmp    init_6c
  170. init_6b:
  171.     cmp    si,offset init_6_tend - 6
  172.     je    init_6c
  173.     add    si,6
  174.     jmp    init_6a
  175. init_6c:
  176.     mov    ax,[si]
  177.     push    si
  178.     int    10h
  179.     pop    si
  180.     mov    cx,[si+2]
  181.     mov    dx,[si+4]
  182.  
  183.     push    ax
  184.     push    dx
  185.     mov     dx,01ceh   ; ATI register : ensure that separed R/W is enable
  186.     mov    al,0beh    ; Register 2
  187.     out     dx,al
  188.     inc     dx
  189.     in      al,dx
  190.     dec    dx
  191.     mov        ah,al
  192.     or        ah,008h    ; set R/W enable
  193.     mov     al,0beh
  194.     out     dx,ax
  195.     pop     dx
  196.     pop     ax
  197.  
  198.     ret
  199.  
  200. init_7: ; biggest non-interlaced graphics
  201.         mov     ax,64h
  202.     int    10h
  203.         mov     cx,1024
  204.         mov     dx,768
  205.  
  206.     push    ax
  207.     push    dx
  208.     mov     dx,01ceh   ; ATI register : ensure that separed R/W is enable
  209.     mov    al,0beh    ; Register 2
  210.     out     dx,al
  211.     inc     dx
  212.     in      al,dx
  213.     dec    dx
  214.     mov        ah,al
  215.     or        ah,008h    ; set R/W enable
  216.     mov     al,0beh
  217.     out     dx,ax
  218.     pop     dx
  219.     pop     ax
  220.  
  221.     ret
  222.  
  223. init_8: ; biggest graphics
  224.         mov     ax,64h
  225.     int    10h
  226.         mov     cx,1024
  227.         mov     dx,768
  228.  
  229.     push    ax
  230.     push    dx
  231.     mov     dx,01ceh   ; ATI register : ensure that separed R/W is enable
  232.     mov    al,0beh    ; Register 2
  233.     out     dx,al
  234.     inc     dx
  235.     in      al,dx
  236.     dec    dx
  237.     mov        ah,al
  238.     or        ah,008h    ; set R/W enable
  239.     mov     al,0beh
  240.     out     dx,ax
  241.     pop     dx
  242.     pop     ax
  243.  
  244.     ret
  245.  
  246. init_routine    endp
  247.  
  248. ;--------------------------------------------------------------------------
  249. ; Entry: AH=read page
  250. ;        AL=write page
  251. ;
  252. ; NOTE: This runs in protected mode!  Don't mess with the segment registers!
  253. ; This code must be relocatable and may not reference any data!
  254. ;
  255. ; Exit: VGA configured.
  256. ;       AX,BX,CX,DX,SI,DI may be trashed
  257. ;
  258. ; Source: Advanced Programmer's Guide To SuperVGAs
  259. ;
  260.  
  261.     assume    ds:nothing, es:nothing
  262.  
  263. paging_routine    proc    FAR
  264.                                 ; TH 30-11-93: Replace 07h by 0Fh
  265.         and     ah,0Fh          ; Read-plane on bits (8-)7-6-5
  266.     ror     ah,1
  267.     ror     ah,1
  268.     ror     ah,1
  269.                                 ; TH 30-11-93: Replace 07h by 0Fh
  270.         and     al,0Fh          ; Write-plane on bits (4-)3-2-1
  271.     shl     al,1
  272.  
  273.     or      ah,al           ; Combine Read and Write plane
  274.  
  275.     mov     dx,01ceh       ; ATI register
  276.     mov     al,0b2h         ; plane select
  277.     out     dx,ax
  278.     ret
  279. paging_routine    endp
  280.  
  281. cseg    ends
  282.     end
  283.  
  284.